package inter.gui.cadastro;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.text.ParseException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.text.MaskFormatter;
import javax.swing.text.PlainDocument;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JFormattedTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import org.eclipse.wb.swing.FocusTraversalOnArray;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class JfCliente extends JFrame {

	private JPanel contentPane;
	private JTextField tfNome;
	private JTextField textField_1;
	private JTextField textField_2;
	private MaskFormatter cpf1;
	private JTextField textField;
	JFormattedTextField formattedTextField;
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JfCliente frame = new JfCliente();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 * @throws ParseException 
	 */
	public JfCliente() throws ParseException {
		setTitle("Cadastro Cliente");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1280, 800);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel lblNome = new JLabel("Nome");
		lblNome.setBounds(129, 0, 50, 14);
		panel.add(lblNome);
		
		tfNome = new JTextField();
		tfNome.addKeyListener(new KeyAdapter() {
			@Override
			public void keyReleased(KeyEvent e) {
				tfNome.setText(tfNome.getText().toUpperCase());
			}
		});
		tfNome.setBounds(129, 22, 659, 18);
		panel.add(tfNome);
		tfNome.setColumns(10);
		
		JLabel lblCod = new JLabel("COD");
		lblCod.setBounds(12, 0, 70, 14);
		panel.add(lblCod);
		
		textField_1 = new JTextField();
		textField_1.setBounds(12, 22, 78, 18);
		panel.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel lblRg = new JLabel("RG");
		lblRg.setBounds(814, 0, 70, 14);
		panel.add(lblRg);
		
		textField_2 = new JTextField();
		textField_2.setBounds(814, 22, 140, 18);
		panel.add(textField_2);
		textField_2.setColumns(10);
		
		JLabel lblCpf = new JLabel("CPF");
		lblCpf.setBounds(988, 0, 70, 14);
		panel.add(lblCpf);
		
	    formattedTextField = new JFormattedTextField(new MaskFormatter("###.###.###-##"));	 
		formattedTextField.setBounds(988, 22, 117, 18);
		panel.add(formattedTextField);
		
		
		
		textField = new JTextField();
		textField.setBounds(991, 59, 114, 18);
		panel.add(textField);
		textField.setColumns(10);
		
		JButton btnNewButton = new JButton("New button");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
			}
		});
		btnNewButton.setBounds(29, 159, 117, 24);
		panel.add(btnNewButton);
		
		JFormattedTextField formattedTextField_1 = new JFormattedTextField(new MaskFormatter("##/##/####"));
		formattedTextField_1.setBounds(1117, 22, 83, 18);
		panel.add(formattedTextField_1);
		panel.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]{tfNome, textField_1, textField_2, formattedTextField, btnNewButton, textField, lblCpf, lblRg, lblCod, lblNome}));
		
		//textField.setText(JFormattedTextField.getDefaultLocale());
		
		
		
	}
}
